/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aviso.facade;

import aviso.entity.AreaType;
import aviso.entity.Building;
import aviso.entity.GroupName;
import aviso.entity.UserName;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author avgusti
 */
@Stateless
public class InitFacade {
    @PersistenceContext(unitName = "aviso")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public InitFacade() {
    }

    public void intDB()
    {
        GroupName g;
        AreaType at;
        g=new GroupName(1l,"admin");
        em.persist(g);
        g=new GroupName(2l,"user");
        em.persist(g);
        g=new GroupName(3l,"stuff");
        em.persist(g);
        
        at=new AreaType(1l,"region");
        em.persist(at);
        at=new AreaType(2l,"district");
        em.persist(at);
        at=new AreaType(3l,"city");
        em.persist(at);
        at=new AreaType(4l,"citydistrict");
        em.persist(at);
        at=new AreaType(5l,"street");
        em.persist(at);
        
        UserName un=new UserName();
        un.setName("admin");
        un.setPasshash("„л$zъЉhVгWN¶Ї¬№€");
        un.setGroup(em.find(GroupName.class, 1l));
        un.setType(UserName.Type.PERSON);
        un.setDisplayname("Admin");
        un.setEmail("avgusti@mail.ru");
        un.setLocale("en");
        em.persist(un);
        
        
    }
}
